/*
 *  MonomeOrientation.java
 *
 *  copyright (c) 2006, tom dinchak & lorenzo orselli
 * 
 *  this file is part of jserialio.
 *
 *  jserialio is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  jserialio is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  You should have received a copy of the GNU General Public License
 *  along with jserialio; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *
 *  created on July 28, 2006, 7:58 PM
 *  
 */

package serialio;

/**
*
* @author lorenzo
*/
public class MonomeOrientation {

	   public int[] getMonomeCoord (String co, int xInVal, int yInVal) {
	       int[] coord = new int[2];
	       coord[0] = xInVal;
	       coord[1] = yInVal;
	      
	       if (co == "L") {
	           /* x' y' -> x '' y '' */
	           coord[0] = xInVal;
	           coord[1] = yInVal;
	       }

	       if (co == "D") {
	           /* x' y' -> y'' 7-x'' */
	           coord[0] = yInVal;
	           coord[1] = 7 - xInVal;
	          
	       }

	       if (co == "R") {
	           /* x' y' -> y''' 7-x''' -> y'' 7-x'' (down x 2) */
	           int xValTemp = yInVal;
	           int yValTemp = 7 - xInVal;
	           coord[0] = yValTemp;
	           coord[1] = 7 - xValTemp;
	          
	       }

	       if (co == "U") {
	           /* x' y' -> 7 - y'' x'' */
	           coord[0] = 7 - yInVal;
	           coord[1] = xInVal;
	       }

	      
	       return coord;
	   } 

	   public int[] setMonomeCoord (String co, int xInVal, int yInVal) {
	       int[] coord = new int[2];
	       coord[0] = xInVal;
	       coord[1] = yInVal;
	      
	       if (co == "L") {
	           /* x' y' -> x '' y '' */
	           coord[0] = xInVal;
	           coord[1] = yInVal;
	       }

	       if (co == "D") {
	           /* x' y' -> y'' 7-x'' */
	           coord[0] = 7 - xInVal;
	           coord[1] = yInVal;
	          
	       }

	       if (co == "R") {
	           /* x' y' -> y''' 7-x''' -> y'' 7-x'' (down x 2) */
	           int xValTemp = yInVal;
	           int yValTemp = 7 - xInVal;
	           coord[0] = yValTemp;
	           coord[1] = 7 - xValTemp;
	          
	       }

	       if (co == "U") {
	           /* x' y' -> x'' 7 - y'' */
	           coord[0] = xInVal;
	           coord[1] = 7 - yInVal;
	       }

	      
	       return coord;
	   } 
	   
	   
}
